package com.easyweb.session;

import com.easyweb.entity.*;

import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.framework.EntityQuery;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import javax.persistence.EntityManager;

@Name("bankaTanimlariList")
public class BankaTanimlariList extends EntityQuery<BankaTanimlari> {

	@In EntityManager entityManager;
	private static final String EJBQL = "select bankaTanimlari from BankaTanimlari bankaTanimlari";

	private List<BankaTanimlari> bankaTanimlariList=null; 
	
	private static final String[] RESTRICTIONS = {
			"lower(bankaTanimlari.bankaAdi) like lower(concat(#{bankaTanimlariList.bankaTanimlari.bankaAdi},'%'))",
			"lower(bankaTanimlari.bankaKodu) like lower(concat(#{bankaTanimlariList.bankaTanimlari.bankaKodu},'%'))", };

	private BankaTanimlari bankaTanimlari = new BankaTanimlari();

	public BankaTanimlariList() {
		 
		setEjbql(EJBQL);
		setRestrictionExpressionStrings(Arrays.asList(RESTRICTIONS));
		setMaxResults(25);
	}
	
	public void bankaTanimlariListOlustur(){
		bankaTanimlariList=new ArrayList<BankaTanimlari>();
		bankaTanimlariList=entityManager.createNamedQuery("bankaTumKayitlar").getResultList();
	}

	public BankaTanimlari getBankaTanimlari() {
		return bankaTanimlari;
	}

	public List<BankaTanimlari> getBankaTanimlariList() {
		if (bankaTanimlariList==null) bankaTanimlariListOlustur();
		return bankaTanimlariList;
	}

	public void setBankaTanimlariList(List<BankaTanimlari> bankaTanimlariList) {
		this.bankaTanimlariList = bankaTanimlariList;
	}
}
